package com.tt.payee.filter.webFliters;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;


/**
 * @author ：Tang
 * @date ：Created in 2020/8/19 14:38
 * @description：
 * @modified By：
 * @version: $
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private CorsFilter corsFilter;

    @Resource
    private PlatformFilter platformFilter;

    @Resource
    private TokenFilter tokenFilter;

    @Resource
    private PermissionFilter permissionFilter;

    //要pass的路由写这里
    private final String[] passUrl = {
            "/auth/login",
            "/terminal/auth/miniAuth",
            "/terminal/auth/authPhoneNumber",
            "/terminal/auth/loginWithValidateCode",
            "/terminal/auth/getValidateCode"
    };

    String[] getPassUrl(){
        return passUrl;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(corsFilter).addPathPatterns("/**");    // 拦截所有请求，通过判断是否有 @LoginRequired 注解 决定是否需要登录
        registry.addInterceptor(platformFilter).addPathPatterns("/**");
        registry.addInterceptor(tokenFilter).addPathPatterns("/**");
        registry.addInterceptor(permissionFilter).addPathPatterns("/**");


    }

}
